<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../css/common/swiper/swiper.min.css"/>
    <style>
        .flex{display: -webkit-box; display: -webkit-flex; display: flex;}
        html,body{
            background-color: white;
        }
        .not-active {
            display: none;
        }
        #header {
            width: 100%;
            height: 2.65rem;
            background-size: 3.75rem auto;
            background-image: url(../image/inquiry/infoHeaderBackground.png);
        }
        #mail-tag {
            min-width: 0.12rem;
            height: 0.12rem;
            background-color: #FE5757;
            border-radius: 0.06rem;
            padding-left: 0.005rem;
            padding-right: 0.005rem;
            position: absolute;
            right:-0.06rem;
            top:-0.06rem;
        }
        #user-image {
            width: 0.70rem;
            height: 0.70rem;
            border-radius: 0.35rem;
            background-size: 0.70rem 0.70rem;
            margin-left: 0.20rem;
            margin-right: 0.16rem;
            position: relative;
        }
        #member-tag {
            width: 0.17rem;
            height: 0.17rem;
            border-radius: 0.085rem;
            background-color: #FFFFFF;
            justify-content: center;
            align-items: center;
            position: absolute;
            right:0.04rem;
            bottom:0.04rem;
        }
        #member-img {
            width: 0.15rem;
            height: 0.15rem;
            border-radius: 0.075rem;
            background-size: 0.15rem 0.15rem;
        }
        .arrow-01 {
            width: 0.09rem;
            height: 0.16rem;
            background-size: 0.09rem 0.16rem;
            background-image: url("../image/my/arrow01.png");
        }
        .arrow-02 {
            width: 0.12rem;
            height: 0.12rem;
            background-size: 0.12rem 0.12rem;
            background-image: url("../image/my/arrow02.png");
            margin-right: 0.20rem;
        }
        .swiper-slide-product{
            width: 1.68rem;
            height: 0.64rem;
            margin-left: 0.15rem;
            background-size: 1.68rem 0.64rem;
            border-radius: 0.04rem;
        }
        p {
            white-space:nowrap;
            text-overflow:ellipsis;
            overflow:hidden;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            word-break:break-all;
            -webkit-line-clamp: 1; /* 控制显示的行数 */
        }
        .master-img {
            width: 0.50rem;
            height: 0.50rem;
            background-size: 0.50rem 0.50rem;
            border-radius: 0.25rem;
        }
        .booking-button-cancel {
            width: 0.80rem;
            height: 0.36rem;
            border-radius: 0.225rem;
            font-size: 0.12rem;
            line-height: 0.36rem;
            text-align: center;
            color: white;
            background-color: #FE5757;
        }
        .booking-button-none {
            width: 0.80rem;
            height: 0.36rem;
            border-radius: 0.225rem;
            font-size: 0.12rem;
            line-height: 0.36rem;
            text-align: center;
            color: white;
            background-color: #C4C5CE;
        }
        .booking-button-watch {
            width: 0.80rem;
            height: 0.36rem;
            border-radius: 0.225rem;
            font-size: 0.12rem;
            line-height: 0.36rem;
            text-align: center;
            color: white;
            background-color: #3E86FF;
        }
        .list-icon {
            width: 0.20rem;
            height: 0.20rem;
            background-size: 0.20rem 0.20rem;
            margin-right: 0.12rem;
        }
    </style>
</head>
<body>
    <div id="header" class="flex" style="flex-wrap: wrap; position: relative; align-content: flex-start;">
        <div class="flex" style="width: 100%; justify-content: flex-end;">
            <div class="flex" style="width: 0.64rem; height: 0.36rem; justify-content: center; align-items: center;" tapmode onclick="">
                <div id="mail" style="width: 0.21rem; height: 0.18rem; background-size: 0.21rem 0.18rem; background-image: url('../image/my/mail-icon.png'); position: relative;" tapmode onclick="openMsg()">
                    <div id="mail-tag" class="not-active">
                        <p id="mail-num" style="font-size: 0.09rem; color: #FFFFFF; width: 100%; text-align: center;"></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="flex" style="height: 0.70rem; align-items: center;" tapmode onclick="openUserInfo()">
            <div id="user-image">
                <div id="member-tag" class="flex not-active">
                    <div id="member-img"></div>
                </div>
            </div>
            <div class="flex" style="width: 2.50rem; height: 0.53rem; justify-content: space-between; align-items: center">
                <div>
                    <p id="user-name" style="font-size: 0.20rem; line-height: 0.28rem; color: #FFFFFF; font-weight: 600; margin-bottom: 0.03rem"></p>
                    <p id="user-phone" style="font-size: 0.16rem; line-height: 0.22rem; color: #FFFFFF;"></p>
                </div>
                <div class="arrow-01"></div>
            </div>
        </div>

        <div id="czyl" class="not-active">
            <div class="flex" style="width: 100%; height: 0.28rem; justify-content: space-between; align-items: flex-end; margin-top: 0.15rem;"  tapmode onclick="openMember(0)">
                <p style="font-size: 0.20rem; line-height: 0.28rem; color: white; margin-left: 0.20rem">储值有礼</p>
                <p style="font-size: 0.14rem; line-height: 0.20rem; color: white; margin-right: 0.20rem; font-weight: 200">立即充值</p>
            </div>
            <div class="swiper-container" id="product-swiper-container" style="width: 100%; height: 0.64rem; margin-top: 0.08rem">
                <div class="swiper-wrapper" id="product-swiper-wrapper"></div>
            </div>
        </div>

        <div id="haveBooking" class="flex not-active" style="width: 100%; position: absolute; bottom: -0.55rem; justify-content: center;">
            <!--<div class="flex" style="width: 100%; height: 0.64rem; justify-content: flex-end" tapmode onclick="openBookingHistory()">-->
                <!--<div class="flex" style="width: 3.55rem; height: 0.64rem; align-items: center; border-style: solid; border-bottom-width: 0.01rem; border-color: #EEEEEE">-->
                    <!--<div class="flex" style="width: 100%; height: 0.28rem; justify-content: space-between; align-items: flex-end;">-->
                        <!--<p style="font-size: 0.20rem; line-height: 0.28rem; color: #26344C;">正在预约</p>-->
                        <!--<p style="font-size: 0.14rem; line-height: 0.20rem; color: #4E81FB; margin-right: 0.20rem; font-weight: 600">历史预约列表</p>-->
                    <!--</div>-->
                <!--</div>-->
            <!--</div>-->
        </div>
        <div id="noBooking" class="flex not-active" style="width: 100%; position: absolute; bottom: -0.55rem; justify-content: center;">
            <div class="flex" style="width: 3.43rem; height: 0.80rem; justify-content: space-between; align-items: center; background-color: white; border-radius: 0.04rem; box-shadow: 0rem 0.02rem 0.08rem rgba(0,0,0,0.13);">
                <div style="margin-left: 0.20rem;">
                    <p style="font-size: 0.16rem; color: #231313;">暂无预约</p>
                    <p style="font-size: 0.12rem; color: #A0522C;">成为金牌会员进行预约</p>
                </div>
                <div style="width: 0.80rem; height: 0.36rem; border-radius: 0.225rem; background-color: #A0522C; margin-right: 0.39rem">
                    <p style="width: 100%; font-size: 0.12rem; line-height: 0.36rem; text-align: center; color: #FFFFFF;">立即预约</p>
                </div>
            </div>
        </div>

    </div>
    <!--<div style="width: 100%; height: 1.65rem; background-color: #FFFFFF;" id="czyl" class="not-active">-->
        <!--<div style="width: 100%; height: 0.20rem;"></div>-->
        <!--<div class="flex" style="width: 100%; height: 0.28rem; justify-content: space-between; align-items: flex-end; margin-bottom: 0.14rem;"  tapmode onclick="openMember(0)">-->
            <!--<p style="font-size: 0.20rem; line-height: 0.28rem; color: #26344C; margin-left: 0.20rem">储值有礼</p>-->
            <!--<p style="font-size: 0.14rem; line-height: 0.20rem; color: #4E81FB; margin-right: 0.20rem; font-weight: 600">立即充值</p>-->
        <!--</div>-->
        <!--<div class="swiper-container" id="product-swiper-container" style="width: 100%; height: 0.83rem;">-->
            <!--<div class="swiper-wrapper" id="product-swiper-wrapper"></div>-->
        <!--</div>-->
    <!--</div>-->

    <!--<div id="haveBooking" class="not-active" style="width: 100%; background-color: #FFFFFF; margin-top: 0.08rem;">-->
        <!--<div class="flex" style="width: 100%; height: 0.64rem; justify-content: flex-end" tapmode onclick="openBookingHistory()">-->
            <!--<div class="flex" style="width: 3.55rem; height: 0.64rem; align-items: center; border-style: solid; border-bottom-width: 0.01rem; border-color: #EEEEEE">-->
                <!--<div class="flex" style="width: 100%; height: 0.28rem; justify-content: space-between; align-items: flex-end;">-->
                    <!--<p style="font-size: 0.20rem; line-height: 0.28rem; color: #26344C;">正在预约</p>-->
                    <!--<p style="font-size: 0.14rem; line-height: 0.20rem; color: #4E81FB; margin-right: 0.20rem; font-weight: 600">历史预约列表</p>-->
                <!--</div>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
    <!--<div id="noBooking" class="not-active" style="width: 100%; height: 1.50rem; background-color: #FFFFFF; margin-top: 0.08rem;">-->
        <!--<div style="width: 100%; height: 0.25rem"></div>-->
        <!--<p style="width: 100%; font-size: 0.20rem; line-height: 0.28rem; color: #26344C; text-align: center;">暂无预约</p>-->
        <!--<p style="width: 100%; font-size: 0.16rem; line-height: 0.22rem; color: #26344C; text-align: center; margin-top: 0.03rem;">成为金牌会员进行预约</p>-->
        <!--<div class="flex" style="width: 100%; height: 0.36rem; margin-top: 0.10rem; justify-content: center">-->
            <!--<div style="width: 0.80rem; height: 0.36rem; border-radius: 0.225rem; background-color: #3E86FF">-->
                <!--<p style="width: 100%; font-size: 0.12rem; line-height: 0.36rem; text-align: center; color: #FFFFFF;">立即预约</p>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->

    <div style="width: 100%; margin-top: 0.75rem; background-color: #FFFFFF;">
        <p style="font-size: 0.18rem; font-weight: 600; color: #231313; margin-top: 0.20rem; margin-left: 0.16rem; margin-bottom: 0.12rem">其他服务</p>
        <div class="flex not-active" style="width: 100%; height: 0.60rem; justify-content: flex-end; align-items: center;" id="scdd">
            <div class="flex" style="width: 3.59rem; height: 0.60rem; justify-content: space-between; align-items: center; border-style: solid; border-bottom-width: 0.01rem; border-color: #EEEEEE;">
                <div class="flex">
                    <div class="list-icon" style="background-image: url('../image/my/order-icon.png')"></div>
                    <p style="font-size: 0.14rem; color: #231313;">商城订单</p>
                </div>
                <div class="arrow-02"></div>
            </div>
        </div>
        <div class="flex not-active" style="width: 100%; height: 0.60rem; justify-content: flex-end; align-items: center;" tapmode onclick="openPay()" id="czjl">
            <div class="flex" style="width: 3.59rem; height: 0.60rem; justify-content: space-between; align-items: center; border-style: solid; border-bottom-width: 0.01rem; border-color: #EEEEEE;">
                <div class="flex">
                    <div class="list-icon" style="background-image: url('../image/my/pay-icon.png')"></div>
                    <p style="font-size: 0.14rem; color: #231313;">充值记录</p>
                </div>
                <div class="arrow-02"></div>
            </div>
        </div>
        <div class="flex" style="width: 100%; height: 0.60rem; justify-content: flex-end; align-items: center;">
            <div class="flex" style="width: 3.59rem; height: 0.60rem; justify-content: space-between; align-items: center; border-style: solid; border-bottom-width: 0.01rem; border-color: #EEEEEE;">
                <div class="flex">
                    <div class="list-icon" style="background-image: url('../image/my/friend-icon.png')"></div>
                    <p style="font-size: 0.14rem; color: #231313;">邀请好友</p>
                </div>
                <div class="arrow-02"></div>
            </div>
        </div>
        <div class="flex" style="width: 100%; height: 0.60rem; justify-content: flex-end; align-items: center;" tapmode onclick="openFeedback()">
            <div class="flex" style="width: 3.59rem; height: 0.60rem; justify-content: space-between; align-items: center; border-style: solid; border-bottom-width: 0.01rem; border-color: #EEEEEE;">
                <div class="flex">
                    <div class="list-icon" style="background-image: url('../image/my/feedback-icon.png')"></div>
                    <p style="font-size: 0.14rem; color: #231313;">意见反馈</p>
                </div>
                <div class="arrow-02"></div>
            </div>
        </div>
        <div class="flex" style="width: 100%; height: 0.60rem; justify-content: flex-end; align-items: center;" tapmode onclick="openInfo()">
            <div class="flex" style="width: 3.59rem; height: 0.60rem; justify-content: space-between; align-items: center; border-style: solid; border-bottom-width: 0.01rem; border-color: #EEEEEE;">
                <div class="flex">
                    <div class="list-icon" style="background-image: url('../image/my/info-icon.png')"></div>
                    <p style="font-size: 0.14rem; color: #231313;">关于我们</p>
                </div>
                <div class="arrow-02"></div>
            </div>
        </div>
    </div>
    <div class="flex" style="margin-top: 0.50rem; height: 0.45rem; justify-content: center;">
        <div style="width: 2.97rem; height: 0.45rem; border-radius: 0.28rem; background-color: #FC5655; font-size: 0.15rem; line-height: 0.45rem; text-align: center; color: #FFFFFF;" tapmode onclick="logOut()">退出登录</div>
    </div>
    <div style="width: 100%; height: 0.15rem;"></div>
</body>
</html>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/common/common.js"></script>
<script type="text/javascript" src="../script/common/swiper/swiper.min.js"></script>
<script type="text/javascript">
    var mailTagEl, mailNumEl, userImgeEl, memberTagEl, memberImgEl, userNameEl, userPhoneEl, haveBookingEl, noBookingEl;
    var userInfo, productList, remainTimeArray = [], memberInfo = [];
    var productSwiper; versionLock = 0;
    apiready = function () {
        $api.byId('header').style.paddingTop = $api.getStorage('safeArea');

        mailTagEl = $api.byId("mail-tag");
        mailNumEl = $api.byId("mail-num");
        userImgeEl = $api.byId("user-image");
        memberTagEl = $api.byId("member-tag");
        memberImgEl = $api.byId("member-img");
        userNameEl = $api.byId("user-name");
        userPhoneEl = $api.byId("user-phone");
        haveBookingEl = $api.byId("haveBooking");
        noBookingEl = $api.byId("noBooking");

        api.setRefreshHeaderInfo({
            bgColor: 'rgba(255, 255, 255, 0)',
            textColor: '#000000',
            textDown: '下拉可以刷新',
            textUp: '松开立即刷新',
            textLoading: '正在刷新数据中',
            textTime: '最后更新'
        }, function(ret, err) {
            window.location.reload();
            api.refreshHeaderLoadDone();
        });

        getUserInfo();

        if ($api.getStorage("version") == 1) {
            $api.removeCls( $api.byId('scdd'), 'not-active');
            $api.removeCls( $api.byId('czyl'), 'not-active');
            $api.removeCls( $api.byId('czjl'), 'not-active');
            getProductList();
        }

        getVersion();
    }

    function getUserInfo() {
        api.ajax({
            url: apiUrl + '/user/info',
            tag: '/user/info',
            method: 'get',
            data: {
                values: {
                    token: $api.getStorage("token"),
                }
            }
        }, function(ret, err) {
            if (ret) {
                if (ret.code == 0) {
                    userInfo = ret.data;

                    $api.css(userImgeEl,'background-image: url(' + userInfo['avatar'] + ');');
                    memberInfo["userImage"] = userInfo['avatar'];
                    switch(parseInt(userInfo['vip']))
                    {
                        case 10:
                            if ($api.getStorage("version") == 1) {
                                $api.removeCls(memberTagEl, "not-active");
                            }
                            $api.css(memberImgEl,'background-image: url("../image/my/yin-icon.png");');
                            memberInfo["memberTag"] = "../../image/my/yin-icon.png";
                            break;
                        case 20:
                            if ($api.getStorage("version") == 1) {
                                $api.removeCls(memberTagEl, "not-active");
                            }
                            $api.css(memberImgEl,'background-image: url("../image/my/jin-icon.png");');
                            memberInfo["memberTag"] = "../../image/my/jin-icon.png";
                            break;
                    }
                    $api.text(userNameEl, userInfo['family_name'] + userInfo['given_name']);
                    $api.text(userPhoneEl, userInfo['phone']);

                    memberInfo["userName"] = userInfo['family_name'] + userInfo['given_name'];
                    memberInfo["userPhone"] = userInfo['phone'];

                    var booking = userInfo['booking'];
                    if (booking.length > 0) {
                        if ($api.getStorage("version") == 1) {
                            $api.removeCls(haveBookingEl, "not-active");
                            // $api.removeCls(noBookingEl, "not-active");
                        }
                        getBooking(booking);
                    } else {
                        if ($api.getStorage("version") == 1) {
                            $api.removeCls(noBookingEl, "not-active");
                        }
                    }

                    // var roomMsg = userInfo['room_msg'];
                    // if (roomMsg.length > 0) {
                    //     $api.removeCls(mailTagEl, "not-active");
                    //     $api.text(mailNumEl, roomMsg.length)
                    // }
                } else {
                    api.toast({
                        msg: ret.err_msg,
                        duration: 2000,
                        location: 'middle'
                    });
                }
            } else {
                // api.alert({ msg: JSON.stringify(err) });
            }
        });
    }

    function getBooking(booking) {
        var haveBooking = $api.byId('haveBooking');
        remainTimeArray = [];

        for (var i=0,len=1; i<len; i++)
        {
            var remainTimeSecond, remainTimeText, bookingButtonClass, bookingButtonText, eventStr;
            remainTimeSecond = booking[i]["begin_time"] - parseInt(new Date().getTime()/1000);

            if (remainTimeSecond > 0) {
                remainTimeArray["rt-" + booking[i]["booking_id"]] = booking[i]["begin_time"];
            }

            if (remainTimeSecond >= (3600*48)) {
                //可取消
                bookingButtonClass = "booking-button-cancel";
                bookingButtonText = "取消预约";
                eventStr = "cancelBooking(" + booking[i]["booking_id"] + ")";
            } else if ((3600*24) < remainTimeSecond < (3600*48)) {
                //不可取消
                bookingButtonClass = "booking-button-none";
                bookingButtonText = "视频连线";
                eventStr = "";
            } else {
                //可观看
                bookingButtonClass = "booking-button-watch";
                bookingButtonText = "视频连线";
                eventStr = "openLiveWin()";
            }

            remainTimeText = remainTime(booking[i]["begin_time"]);

            $api.append(haveBooking, '<div class="flex" style="width: 3.43rem; height: 0.80rem; justify-content: space-between; align-items: center; background-color: white; border-radius: 0.04rem; box-shadow: 0rem 0.02rem 0.08rem rgba(0,0,0,0.13);">' +
                    '<div class="flex" style="align-items: center; margin-left: 0.12rem" tapmode onclick="openBookingHistory()">' +
                        '<div class="master-img" style="background-image: url('+ booking[i]["avatar"] + ');"></div>' +
                        '<div style="height: 0.40rem; margin-left: 0.10rem;">' +
                            '<p style="font-size: 0.16rem; line-height: 0.22rem; color: #231313; margin-bottom: 0.01rem">'+ booking[i]["master_name"] + '</p>' +
                            '<p style="font-size: 0.12rem; line-height: 0.17rem; color: #FC5655">'+ "倒计时：" + remainTimeText + '</p>' +
                        '</div>' +
                    '</div>' +
                    '<div class="flex" style="align-items: center">' +
                        '<div class="' + bookingButtonClass + '" style="margin-right: 0.15rem" tapmode onclick="' + eventStr + '">' + bookingButtonText + '</div>' +
                        '<div class="arrow-02" tapmode onclick="openBookingHistory()"></div>' +
                    '</div>' +
                '</div>');
        }
        // if (remainTimeSecond.length > 0) {
        //     //轮训倒计时
        // }
    }

    function getProductList() {
        var productSwiperWrapper = $api.byId('product-swiper-wrapper');
        productList = [
            {
                "product_name": "金牌会员",
                "product_desc": "风水医道大师一对一服务",
                "background": "../image/my/background-jin.png"
            },
            {
                "product_name": "银牌会员",
                "product_desc": "无限制观看大相培训课程",
                "background": "../image/my/background-yin.png"
            }
        ];
        for (var i=0,len=productList.length; i<len; i++)
        {
            $api.append(productSwiperWrapper,'<div id=' + "p-" + i + ' class="swiper-slide swiper-slide-product" style="background-image: url('+ productList[i]["background"] + ');" tapmode onclick="openMember(' + i + ')">' +
                    '<div class="flex" style="width: 100%; height: 0.34rem; justify-content: center;">' +
                        '<div class="flex" style="width: 1.44rem; height: 0.34rem; align-items: flex-end;">' +
                            '<p style="font-size: 0.16rem; color: #633331;">'+ productList[i]["product_name"] + '</p>' +
                        '</div>' +
                    '</div>' +
                    '<div class="flex" style="width: 100%; height: 0.19rem; justify-content: center;">' +
                        '<div class="flex" style="width: 1.44rem; height: 0.19rem; align-items: center;">' +
                            '<p style="font-size: 0.12rem; color: #633331; font-weight: 200">'+ productList[i]["product_desc"] + '</p>' +
                        '</div>' +
                    '</div>' +
                '</div>');
        }
        productSwiper = new Swiper ('#product-swiper-container', {
            freeMode : true,
            slidesPerView : "auto",
        });

        // api.ajax({
        //     url: apiUrl + '/buy/product-list',
        //     tag: '/buy/product-list',
        //     method: 'get',
        //     data: {
        //         values: {
        //             token: $api.getStorage("token"),
        //             device_type: api.systemType
        //         }
        //     }
        // }, function(ret, err) {
        //     if (ret) {
        //         if (ret.code == 0) {
        //             productList = ret.data.product_list;
        //
        //             var productSwiperWrapper = $api.byId('product-swiper-wrapper');
        //
        //             for (var i=0,len=productList.length; i<len; i++)
        //             {
        //                 var background;
        //                 switch(i)
        //                 {
        //                     case 0:
        //                         background = "../image/my/background-yin.png";
        //                         break;
        //                     case 1:
        //                         background = "../image/my/background-jin.png";
        //                         break;
        //                 }
        //                 $api.append(productSwiperWrapper,'<div id=' + "p-" + productList[i]['product_id'] + ' class="swiper-slide swiper-slide-product" style="background-image: url('+ background + ');" tapmode onclick="openProductWin(this)">' +
        //                         '<div class="flex" style="width: 100%; height: 0.45rem; justify-content: center;">' +
        //                             '<div class="flex" style="width: 1.35rem; height: 0.45rem; border-style: dashed; border-bottom-width: 0.01rem; border-color: #979797; align-items: center;">' +
        //                                 '<p style="font-size: 0.18rem; color: #26344C; font-weight: 600;">'+ productList[i]["product_name"] + '</p>' +
        //                             '</div>' +
        //                         '</div>' +
        //                         '<div class="flex" style="width: 100%; height: 0.37rem; justify-content: center;">' +
        //                             '<div class="flex" style="width: 1.35rem; height: 0.37rem; align-items: center;">' +
        //                                 '<p style="font-size: 0.12rem; color: #26344C;">'+ productList[i]["product_desc"] + '</p>' +
        //                             '</div>' +
        //                         '</div>' +
        //                     '</div>');
        //             }
        //             productSwiper = new Swiper ('#product-swiper-container', {
        //                 freeMode : true,
        //                 slidesPerView : "auto",
        //             });
        //         } else {
        //             api.toast({
        //                 msg: ret.err_msg,
        //                 duration: 2000,
        //                 location: 'middle'
        //             });
        //         }
        //     } else {
        //         // api.alert({ msg: JSON.stringify(err) });
        //     }
        // });
    }

    function openUserInfo() {
        api.openWin({
            name: 'userInfoWin',
            url: './my/userInfoWin.html',
            slidBackType: 'edge',
            animation: {
                type:"movein",
                subType:"from_right",
                duration:300
            }
        });
    }

    function openMsg() {
        api.openWin({
            name: 'msgWin',
            url: './my/msgWin.html',
            slidBackType: 'edge',
            animation: {
                type:"movein",
                subType:"from_right",
                duration:300
            }
        });
    }

    function openMember(tag) {
        api.openWin({
            name: 'memberWin',
            url: './my/memberWin.html',
            slidBackType: 'edge',
            pageParam: {
                tag: tag,
                userImage: memberInfo["userImage"],
                userTag: memberInfo["memberTag"],
                userName: memberInfo["userName"],
                userPhone: memberInfo["userPhone"],
            },
            animation: {
                type:"movein",
                subType:"from_right",
                duration:300
            }
        });
    }

    function openBookingHistory() {
        api.openWin({
            name: 'bookingHistoryWin',
            url: './my/bookingHistoryWin.html',
            slidBackType: 'edge',
            animation: {
                type:"movein",
                subType:"from_right",
                duration:300
            }
        });
        return false;
    }

    function openPay() {
        api.openWin({
            name: 'payWin',
            url: './my/payWin.html',
            slidBackType: 'edge',
            animation: {
                type:"movein",
                subType:"from_right",
                duration:300
            }
        });
    }

    function openFeedback() {
        api.openWin({
            name: 'feedbackWin',
            url: './my/feedbackWin.html',
            slidBackType: 'edge',
            animation: {
                type:"movein",
                subType:"from_right",
                duration:300
            }
        });
    }

    function openInfo() {
        api.openWin({
            name: 'infoWin',
            url: './my/infoWin.html',
            slidBackType: 'edge',
            animation: {
                type:"movein",
                subType:"from_right",
                duration:300
            }
        });
    }

    function cancelBooking(bookingId) {
        api.ajax({
            url: apiUrl + '/inquiry/cancel-booking',
            tag: '/inquiry/cancel-booking',
            method: 'get',
            data: {
                values: {
                    token: $api.getStorage("token"),
                    booking_id: bookingId,
                }
            }
        }, function(ret, err) {
            if (ret) {
                if (ret.code == 0) {
                    window.location.reload();
                } else {
                    api.toast({
                        msg: ret.err_msg,
                        duration: 2000,
                        location: 'middle'
                    });
                }
            } else {
                // api.alert({ msg: JSON.stringify(err) });
            }
        });
    }

    function openLiveWin() {
        alert("live")
    }

    function reloadUserInfo() {
        window.location.reload();
    }

    function logOut() {
        $api.clearStorage ();
        api.execScript({
            script: "reloadMain()"
        });
        api.setStatusBarStyle({
            style: 'dark',
        });
        api.openWin({
            name: 'loginPage',
            url: './login/login_win.html',
            slidBackEnabled: false,
            animation: {
                type: 'none',
                duration: 0
            }
        });
    }

    function showp() {
        window.location.reload();
    }

    function getVersion() {
        var oldversion = $api.getStorage('version');
        api.ajax({
            url: apiUrl + '/vip/last-version',
            tag: '/vip/last-version',
            method: 'get',
        }, function(ret, err) {
            if (ret) {
                if (ret.code == 0) {
                    var version = ret.data.version + "";
                    version = version.split(".");
                    var systemVersion = api.appVersion.split(".");
                    if (version[2] == undefined) {
                        version[2] = 0;
                    }
                    if (parseInt(systemVersion[0]) == parseInt(version[0])) {
                        if (parseInt(systemVersion[1]) == parseInt(version[1])) {
                            if (parseInt(systemVersion[2]) == parseInt(version[2])) {
                                $api.setStorage('version', 1);
                            } else if (parseInt(systemVersion[2]) < parseInt(version[2])) {
                                $api.setStorage('version', 1);
                            } else if (parseInt(systemVersion[2]) > parseInt(version[2])) {
                                $api.setStorage('version', 0);
                            }
                        } else if (parseInt(systemVersion[1]) < parseInt(version[1])) {
                            $api.setStorage('version', 1);
                        } else if (parseInt(systemVersion[1]) > parseInt(version[1])) {
                            $api.setStorage('version', 0);
                        }
                    } else if (parseInt(systemVersion[0]) < parseInt(version[0])) {
                        $api.setStorage('version', 1);
                    } else if (parseInt(systemVersion[0]) > parseInt(version[0])) {
                        $api.setStorage('version', 0);
                    }
                    if (oldversion != $api.getStorage('version')) {
                        if ($api.getStorage('version') == 0) {
                            api.execScript({
                                name: 'main',
                                script: "hiddenp()"
                            });
                            showp();
                        } else {
                            api.execScript({
                                name: 'main',
                                script: "showp()"
                            });
                            showp();
                        }
                    }
                } else {
                }
            } else {
                // api.alert({ msg: JSON.stringify(err) });
            }
        });
    }
</script>
